<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author markos
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */


/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author markos
 */
class Application_Model_Rol extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(10) unsigned
     *
     * @var int
     */
    protected $_CodigoRol;

    /**
     * Database var type varchar(50)
     *
     * @var string
     */
    protected $_Nombre;



    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'codigo_rol'=>'CodigoRol',
            'nombre'=>'Nombre',
        ));

        $this->setParentList(array(
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column codigo_rol
     *
     * @param int $data
     * @return Application_Model_Rol
     */
    public function setCodigoRol($data)
    {
        $this->_CodigoRol = $data;
        return $this;
    }

    /**
     * Gets column codigo_rol
     *
     * @return int
     */
    public function getCodigoRol()
    {
        return $this->_CodigoRol;
    }

    /**
     * Sets column nombre
     *
     * @param string $data
     * @return Application_Model_Rol
     */
    public function setNombre($data)
    {
        $this->_Nombre = $data;
        return $this;
    }

    /**
     * Gets column nombre
     *
     * @return string
     */
    public function getNombre()
    {
        return $this->_Nombre;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Rol
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Rol());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Rol::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getCodigoRol() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('codigo_rol = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getCodigoRol()));
    }
}
